#include <bits/stdc++.h>

#define eb emplace_back
#define ep emplace
#define fi first
#define se second
#define in read<int>()
#define lin read<ll>()
#define rep(i, x, y) for(int i = (x); i <= (y); i++)
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using vec = vector < int >;
using veg = vector < pii >;

template < typename T > T read() {
	T x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-', ch = getchar();
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

template < typename T > void chkmax(T &x, const T &y) { x = x > y ? x : y; }
template < typename T > void chkmin(T &x, const T &y) { x = x < y ? x : y; }

const int N = 1e5 + 10;
const db eps = 1e-9;

int n, m;
db ans[N];
veg G[N];
pii val[N];
db res;

pii operator + (pii a, pii b) { return pii(a.fi + b.fi, a.se + b.se); }
pii operator - (pii a, pii b) { return pii(a.fi - b.fi, a.se - b.se); }

bool vis[N];
vec pot;
vector < tuple < int, int, int > > ale;

void dfs(int x) {
	vis[x] = true; pot.eb(x);
	for(auto v : G[x]) {
		int y, w; tie(y, w) = v;
		if(!vis[y]) val[y] = pii(0, w) - val[x], dfs(y);
		else if((val[x] + val[y]).fi != 0) ale.eb(x, y, w);
		else if((val[x] + val[y]).se != w) puts("NO"), exit(0);
	}
}

void solve(int x) {
	ale.clear(); pot.clear(); val[x] = { 1, 0 }; dfs(x);
	bool havc = 0; res = 0;
	for(auto v : ale) {
		int a, b, c; tie(a, b, c) = v;
		if((val[a] + val[b]).fi != 0) {
			db tres = 1. * (c - val[a].se - val[b].se) / (val[a] + val[b]).fi;
			if(!havc) havc = true, res = tres;
			else if(fabs(res - tres) > eps) puts("NO"), exit(0);
		}
	}
	if(havc) { for(auto y : pot) ans[y] = val[y].fi * res + val[y].se; return; }
	else {
		vec t;
		for(auto y : pot) {
			assert(val[y].fi == 1 || val[y].fi == -1);
			if(val[y].fi == 1) t.eb(-val[y].se);
			else t.eb(val[y].se);
		}
		sort(t.begin(), t.end());
		res = t[t.size() / 2];
		for(auto y : pot) ans[y] = val[y].fi * res + val[y].se;
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);// freopen("1.out", "w", stdout);
#endif
	n = in, m = in;
	rep(i, 1, m) {
		int a = in, b = in, c = in;
		G[a].eb(b, c); G[b].eb(a, c);
	}
	rep(i, 1, n) if(!vis[i]) solve(i);
	puts("YES"); rep(i, 1, n) printf("%.7lf ", ans[i]);
	puts("");
	return 0;
}
